/* eslint-disable prefer-const */
import Vue from 'vue'
import Cookies from 'js-cookie'
import Element from 'element-ui'
import 'animate.css'
import VueAnimXYZ from '@animxyz/vue'
import '@animxyz/core'
import './assets/styles/element-variables.scss'
import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive
import plugins from './plugins' // plugins
import dataV from '@jiaminghi/data-view'
import './assets/icons' // icon
import './echartTheme'
// 大屏整体框架组件
import FullScreenContainer from '@/layout'
// 大屏模块组件
import Panel from '@/components/Panel'
import pinia from './pinia/index'
import { PiniaVuePlugin } from 'pinia'
import TopNav from '@/layout/components/TopNav'
import api from './api/api.js'
import importImg from '@/utils/importImg'

Vue.use(PiniaVuePlugin)
Vue.use(api)
Vue.use(importImg)
Vue.use(VueAnimXYZ)

// 全局组件挂载
Vue.component('FullScreenContainer', FullScreenContainer)
Vue.component('Panel', Panel)
Vue.component('TopNav', TopNav)
import { install as installGlobalComponent } from './globalComponent/globalComponent.js'
Vue.use(directive)
Vue.use(plugins)
Vue.use(dataV)
Vue.use(installGlobalComponent)
Vue.prototype.numberFormat = (num) => {
  // 分离整数和小数部分
  let [integerPart, decimalPart] = num.toString().split('.')

  // 只对整数部分添加千分位逗号
  integerPart = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')

  // 将整数和小数部分合并
  return integerPart + (decimalPart ? '.' + decimalPart : '')
}
// 修改 el-dialog 默认点击遮照为不关闭
Element.Dialog.props.closeOnClickModal.default = false

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  pinia,
  store,
  render: h => h(App)
})
